﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using nelech.Models;
using nelech.Models.DBModel;
using System.Text;

namespace nelech.Views.Shared.Code
{
    public class TrafficComparer : IEqualityComparer<Traffic>
    {
        #region IEqualityComparer<Traffic> Members

        public bool Equals(Traffic x, Traffic y)
        {
            return x.id == y.id;
        }

        public int GetHashCode(Traffic obj)
        {
            return obj.GetHashCode();
        }

        #endregion
    }

    public class SeasonComparer : IEqualityComparer<Season>
    {
        #region IEqualityComparer<Season> Members

        public bool Equals(Season x, Season y)
        {
            return x.id == y.id;
        }

        public int GetHashCode(Season obj)
        {
            return obj.GetHashCode();
        }

        #endregion
    }

    public class SubjectComparer : IEqualityComparer<Subject>
    {
        #region IEqualityComparer<Subject> Members

        public bool Equals(Subject x, Subject y)
        {
            return x.id == y.id;
        }

        public int GetHashCode(Subject obj)
        {
            return obj.GetHashCode();
        }

        #endregion
    }

    public class TypeComparer : IEqualityComparer<nelech.Models.DBModel.Type>
    {
        #region IEqualityComparer<Type> Members

        public bool Equals(nelech.Models.DBModel.Type x, nelech.Models.DBModel.Type y)
        {
            return x.id == y.id;
        }

        public int GetHashCode(nelech.Models.DBModel.Type obj)
        {
            return obj.GetHashCode();
        }

        #endregion
    }
    public class AdvertComparer : IEqualityComparer<nelech.Models.DBModel.AdvertPlace>
    {
        #region IEqualityComparer<AdvertPlace> Members

        public bool Equals(nelech.Models.DBModel.AdvertPlace x, nelech.Models.DBModel.AdvertPlace y)
        {
            return x.id == y.id;
        }

        public int GetHashCode(nelech.Models.DBModel.AdvertPlace obj)
        {
            return obj.GetHashCode();
        }

        #endregion
    }
   
    public class SizeComparer : IEqualityComparer<nelech.Models.DBModel.Size>
    {
        #region IEqualityComparer<Size> Members

        public bool Equals(nelech.Models.DBModel.Size x, nelech.Models.DBModel.Size y)
        {
            return x.id == y.id;
        }

        public int GetHashCode(nelech.Models.DBModel.Size obj)
        {
            return obj.GetHashCode();
        }

        #endregion
    }

    public class AttrTypeComparer : IEqualityComparer<nelech.Models.DBModel.AttractionType>
    {
        #region IEqualityComparer<Size> Members

        public bool Equals(nelech.Models.DBModel.AttractionType x, nelech.Models.DBModel.AttractionType y)
        {
            return x.id == y.id;
        }

        public int GetHashCode(nelech.Models.DBModel.AttractionType obj)
        {
            return obj.GetHashCode();
        }

        #endregion
    }
    public class RecommendedTrackComparer : IEqualityComparer<RecommendedTrack>
    {
        #region IEqualityComparer<RecommendedTrack> Members

        public bool Equals(RecommendedTrack x, RecommendedTrack y)
        {
            return x.id == y.id;
        }

        public int GetHashCode(RecommendedTrack obj)
        {
            return obj.GetHashCode();
        }

        #endregion
    }
    public class RecommendedSpringComparer : IEqualityComparer<RecommendedSpring>
    {
        #region IEqualityComparer<RecommendedSpring> Members

        public bool Equals(RecommendedSpring x, RecommendedSpring y)
        {
            return x.id == y.id;
        }

        public int GetHashCode(RecommendedSpring obj)
        {
            return obj.GetHashCode();
        }

        #endregion
    }
    public class RecommendedPlaceComparer : IEqualityComparer<RecommendedPlace>
    {
        #region IEqualityComparer<RecommendedPlace> Members

        public bool Equals(RecommendedPlace x, RecommendedPlace y)
        {
            return x.id == y.id;
        }

        public int GetHashCode(RecommendedPlace obj)
        {
            return obj.GetHashCode();
        }

        #endregion
    }

    public class ImagePathComparer : IComparer<string>
    {
        #region IComparer<string> Members

        public int Compare(string x, string y)
        {
            var xnum = ExtractNumber(x);
            var ynum = ExtractNumber(y);
            return xnum - ynum;
        }

        private int ExtractNumber(string str)
        {
            return int.Parse(str.Substring(15, str.IndexOf("_", 15) - 15));
        }

        #endregion
    }
    public class RegionComparer : IEqualityComparer<Regeon>
    {
        #region IEqualityComparer<Regeon> Members

        public bool Equals(Regeon x, Regeon y)
        {
            return x.id == y.id;
        }

        public int GetHashCode(Regeon obj)
        {
            return obj.GetHashCode();
        }

        #endregion
    }

}
